\subsection{Stokes' theorem}
\index{Stokes' theorem}
Stokes' theorem proves the following equivalence of line and surface
integrals.
%\bigskip
%\noindent
%$\displaystyle{\oint_C P\,dx+Q\,dy+R\,dz}$
%$$=
%\int\!\!\!\int_S
%\left({\partial Q\over\partial x}-{\partial P\over\partial y}\right)\,dx\,dy
%+
%\left({\partial R\over\partial y}-{\partial Q\over\partial z}\right)\,dy\,dz
%+
%\left({\partial P\over\partial z}-{\partial R\over\partial x}\right)\,dz\,dx
%$$
%
%\noindent
%Curve $C$ is the perimeter around $S$.
%The theorem can be also be written as
$$\oint P\,dx+Q\,dy+R\,dz
=\int\!\!\!\int_S(\mathop{\rm curl}{\bf F})\cdot{\bf n}\,d\sigma
$$
where ${\bf F}=(P,Q,R)$.
For $S$ parametrized by $x$ and $y$ we have
$${\bf n}\,d\sigma=\left(
{\partial S\over\partial x}\times{\partial S\over\partial y}
\right)dx\,dy$$
In many cases, converting an integral according to
Stokes' theorem can turn a difficult problem into an easy one.

\medskip
\noindent
Let ${\bf F}=(y,z,x)$ and let $S$ be the part of the paraboloid
$z=4-x^2-y^2$
that is above the $xy$ plane.
The perimeter of the paraboloid is the circle $x^2+y^2=2$.
Calculate both the line and surface integrals.
It turns out that we need to use polar coordinates so that {\it defint} can
succeed.

\medskip
\verb$--Surface integral$

\verb$z=4-x^2-y^2$

\verb$F=(y,z,x)$

\verb$S=(x,y,z)$

\verb$f=dot(curl(F),cross(d(S,x),d(S,y)))$

\verb$x=r*cos(theta)$

\verb$y=r*sin(theta)$

\verb$defint(f*r,r,0,2,theta,0,2pi)$

$$-4\pi$$

\verb$--Line integral$

\verb$x=2*cos(t)$

\verb$y=2*sin(t)$

\verb$z=4-x^2-y^2$

\verb$P=y$

\verb$Q=z$

\verb$R=x$

\verb$f=P*d(x,t)+Q*d(y,t)+R*d(z,t)$

\verb$f=circexp(f)$

\verb$defint(f,t,0,2pi)$

$$-4\pi$$

